package com.hsmpay.common.service;

import com.hsmpay.common.util.system.Constant;

import java.io.Serializable;
import java.util.List;

/**
 * Memcached 顶层服务类接口
 *
 * @param <Entity>
 * @param <Query>
 * @author 颜铃璋
 * @date 2012-12-15
 */
public interface MemcachedService<Entity extends Serializable, Query extends Object> extends BaseService<Entity, Query> {
    public final String WANJX_USER_INFO_DETAIL_KEY = Constant.getAttribute("WANJX_USER_INFO_DETAIL_KEY");//用户信息KEY
    public final String REGISTER_CODE_KEY = Constant.getAttribute("REGISTER_CODE_KEY");//注册手机验证码 KEY

    /**
     * 保存 Memcached 数据
     *
     * @param key
     * @param rootDate
     * @return
     * @throws Exception
     */
    public boolean setCacheData(String key, Object rootDate) throws Exception;

    /**
     * 保存 Memcached 列表
     *
     * @param key
     * @return
     * @throws Exception
     */
    public boolean setCacheList(String key, List<Entity> retEntity) throws Exception;

    /**
     * 获得 Memcached 节点对象
     *
     * @param key
     * @return
     * @throws Exception
     */
    public Object getCacheData(String key) throws Exception;

    /**
     * 判断key对应的 Memcached 节点对象是否存在
     *
     * @param key
     * @return
     * @throws Exception
     */
    public boolean existCacheNode(String key) throws Exception;

    /**
     * 更新 Memcached 数据
     *
     * @param cacheKey
     * @param cacheValue
     * @return
     * @throws Exception
     */
    public boolean replaceCacheNode(String cacheKey, Object cacheValue) throws Exception;

    /**
     * 删除 Memcached 数据
     *
     * @param cacheKey
     * @return
     * @throws Exception
     */
    public boolean removeCacheNode(String cacheKey) throws Exception;


}
